  <script type="text/javascript"><!--//--><![CDATA[//><!--

    $(document).ready(function() {


        // Setup Form
        $('#form_master').setupForm([

            { name: 'kode_mitra', type:'text', size: 'medium', maxlength: 15, readonly:true, noempty:true },
            { name: 'ktp', type:'text', size: 'medium', maxlength: 16, noempty:true },
            { name: 'situ', type:'text', size: 'medium', maxlength: 40},
            { name: 'siup', type:'text', size: 'medium', maxlength: 40},
            { name: 'npwp', type:'text', size: 'medium', maxlength: 40 },
            { name: 'nama_toko_mitra', type: 'text', size: 'medium', noempty:true },
            { name: 'nama_pemilik', type: 'text', size: 'medium', noempty:true },
            { name: 'alamat_lengkap', type: 'text', size: 'medium', noempty:true },
            { name: 'no_telp', type: 'text', size: 'medium' },
            { name: 'no_hand', type: 'text', size: 'medium'},
            { name: 'status_mitra', type: 'text', size: 'medium',  noempty:true },
            { name: 'no_kontrak', type: 'text', size: 'medium',  noempty:true },
            { name: 'awal_kerja', type: 'date', size: 'short',  noempty:true },
            { name: 'akhir_kerja', type: 'date', size: 'short',  noempty:true },
            { name: 'fee_mitra', type: 'text', size: 'medium'},
            { name: 'no_rekening', type: 'text', size: 'medium' },
            { name: 'nama_bank', type: 'text', size: 'medium'},
            { name: 'atas_nama', type: 'text', size: 'medium'},

            ], <?php echo json_encode($data); ?>);
                
        
        
        
        <?php if($mode=="edit"){ ?>
        $('#kode_mitra').readonly();
        $('#id_mitra').setval('<?php echo $id_mitra_edit; ?>');
        <?php } ?>

        $("#mitra-hide").hide();
        $("#mitra2-hide").hide();
        $("#mitra3-hide").hide();
        $("#mitra4-hide").hide();
        $("#mitra5-hide").hide();
        $("#mitra6-hide").hide();
        $("#mitra7-hide").hide();
        $("#mitra8-hide").hide();
        $("#mitra9-hide").hide();

        $("#status_mitra").change(function() {
             var str = "";
             $("#status_mitra option:selected").each(function() {
                str = $(this).text();
             });

             if(str == 'Mitra Aktif'){
                 $("#mitra-hide").hide();
                   
             }
             else if(str == 'Belum Aktif'){
                $("#mitra-hide").hide();
                $("#mitra2-hide").hide();
                $("#mitra3-hide").hide();
                $("#mitra4-hide").hide();
                $("#mitra5-hide").hide();
                $("#mitra6-hide").hide();
                $("#mitra7-hide").hide();
                $("#mitra8-hide").hide();
                $("#mitra9-hide").hide();
             }
             
        });

        // Set Action Button
        var buttons = [{ label: 'Save', icon: 'save', onclick: function() { 
                            $('#form_master').submitForm(   '/'+controller+'/ajax_post',{onComplete : function(){loadPage('/'+controller+'/Index')}}); 
                        }},
                       { label: 'Close', icon: 'cancel', onclick: function() { loadPage('/'+controller+'/Index'); } }];
        setAction(buttons);

        // Focus at First Object
        $('#form_master').focusFirst();
    });




//--><!]]></script>

<div id="form_master_message" style="display:none;"></div>
    <table class="tb_form" style="width:100%;" cellpadding="0" cellspacing="0">
     <tr>
        <td class="label" style="width:150px"><font size ='3px'><strong><u>Data Mitra</u></strong></td>
        <td></td>
     </tr>
     <tr>
         <td>
             <td><input id="id_mitra" name="id_mitra" type="hidden" /></td>
         </td>
     </tr>
     <tr>
        <td class="label" style="width:150px">Kode Mitra</td>
        <td><input id="kode_mitra" /></td>
     </tr>
     <tr>
        <td class="label" style="width:150px">KTP</td>
        <td><input id="ktp" /></td>
     </tr>
     <tr>
        <td class="label" style="width:150px">SITU</td>
        <td><input id="situ" /></td>
     </tr>
     <tr>
        <td class="label" style="width:150px">SIUP</td>
        <td><input id="siup" /></td>
     </tr>
     <tr>
        <td class="label" style="width:150px">NPWP</td>
        <td><input id="npwp" /></td>
     </tr>
     <tr>
        <td class="label" style="width:150px">Nama Pemilik</td>
        <td><input id="nama_pemilik" /></td>
     </tr>
     <tr>
        <td class="label" style="width:150px">Nama Toko Mitra</td>
        <td><input id="nama_toko_mitra" /></td>
     </tr>
     <tr>
        <td class="label" style="width:150px">Alamat Lengkap</td>
        <td><textarea id="alamat_lengkap" name="alamat_lengkap" rows="5" /></td>
     </tr>
     <tr>
        <td class="label" style="width:150px">Nomor Telepon</td>
        <td><input id="no_telp" /></td>
     </tr>
     <tr>
        <td class="label" style="width:150px">Nomor Handphone</td>
        <td><input id="no_hand" /></td>
     </tr>
     <tr><td class="label" style="width:150px">Status Mitra</td>
        <td><select id="status_mitra" name="status_mitra">
                <option value="null">(Pilih Status)</option>
                <option value="Belum Aktif">Belum Aktif</option>
                <option value="Mitra Aktif">Mitra Aktif</option>
                <option value="Mitra Non-Aktif">Mitra Non-Aktif</option>
            </select>
        </td>
     </tr>
     <tr id="mitra-hide">
        <td class="label" style="width:170px"><font size ='3px'><strong><u>Kontrak Kerja Sama</u></strong></td>
        <td></td>
     </tr>
     <tr id="mitra2-hide">
        <td class="label" style="width:150px">No Kontrak</td>
        <td><input id="no_kontrak" /></td>
     </tr>
     <tr id="mitra3-hide">
        <td class="label" style="width:150px">Awal Kerja</td>
        <td><input id="awal_kerja" /></td>
     </tr>
     <tr id="mitra4-hide">
        <td class="label" style="width:150px">Akhir Kerja</td>
        <td><input id="akhir_kerja" /></td>
     </tr>
     <tr id="mitra5-hide">
        <td class="label" style="width:150px">Fee Mitra</td>
        <td><input id="fee_mitra" /></td>
     </tr>
     <tr id="mitra6-hide">
        <td class="label" style="width:150px"><font size ='3px'><strong><u>Bank Mitra</u></strong></td>
        <td></td>
     </tr>
     <tr id="mitra7-hide">
        <td class="label" style="width:150px">No Rekening</td>
        <td><input id="no_rekening" /></td>
     </tr>
     <tr id="mitra8-hide">
        <td class="label" style="width:150px">Nama Bank</td>
        <td><input id="nama_bank" /></td>
     </tr>
     <tr id="mitra9-hide">
        <td class="label" style="width:150px">Atas Nama</td>
        <td><input id="atas_nama" /></td>
     </tr>
</table>
